<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%-- 
    JSP Name : ml_100_03.jsp
    Description : 뉴스레터 리스트
    author Ki min
    since 2012. 7. 24.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 7. 24.     Ki min     최초 생성
--%>
<%@ include file="/WEB-INF/jsp/co/mn/include/declare.jspf" %>
<%@ include file="/WEB-INF/jsp/co/mn/include/session.jspf" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
<%@ include file="/WEB-INF/jsp/co/mn/include/header.jspf" %>
<script type="text/javaScript" language="javascript">
<!--
$(document).ready(function() {
    
    $("#srchButn").bind("click", moveSearch);    // 검색
    $("#rgstButn").bind("click", moveRgstPage);    // 등록
    $("#delButn").bind("click", delSubmit);    // 삭제
    
    $("#srchTxt").bind("keydown", eventEnter);    // 엔터키 제어
});

/*
 * 페이징
 */
function movePage(num) {
    $("#currentPageNo").val(num);
    $("#mainForm").attr('action','/ml_100_03.do').submit();
}

/*
 * 검색
 */
function moveSearch() {
    if (!isSchrChk($("#srchTxt").val())) {
        alert("검색어에는 특수문자를 입력할 수 없습니다.");
        $("#srchTxt").focus();
        return false;
    }
    
    $("#currentPageNo").val("1");
    $("#mainForm").attr('action','/ml_100_03.do').submit();
}

/*
 * 검색 Text EnterKey 처리
 */
function eventEnter() {
    if (event.key == 13) {
        moveSearch();
    }
}

/*
 * 상세페이지 이동
 */
function moveDtlPage(idx) {
    $("#ltrIdx").val(idx);
    $("#mainForm").attr('action','/ml_100_04.do').submit();
}

/*
 * 등록페이지 이동
 */
function moveRgstPage() {
    $("#mainForm").attr('action','/ml_100_05.do').submit();
}

/*
 * 삭제처리
 */
function delSubmit() {
    if(confirm("삭제 하시겠습니까?")){
        if ($("input[name='arrIdx']").length < 1) return;
        
        var delIdx = "";
        
        for (var i = 0; i < $("input[name='arrIdx']").length; i++){
            if ($("input[name='arrIdx']").eq(i).is(":checked") == true ){
                delIdx = delIdx + $("input[name='arrIdx']").eq(i).val() + ","; 
            } 
        }
        
        if (delIdx == "") {
            alert("삭제할 뉴스레터를 선택해 주세요.");
            return;
        }
        
        delIdx = delIdx.substring(0, delIdx.length-1);
        
        $("#delIdx").val(delIdx);
        $("#currentPageNo").val("1");
        
        $("#mainForm").attr('target','comIframe');
        $("#mainForm").attr('action','/ml_100_08.do').submit();
    }
}
//-->
</script>
</head>
<body>
<div id="wrap">
    <!-- top -->
    <%@ include file="/WEB-INF/jsp/co/mn/include/top.jsp" %>
    <!-- top -->

    <!-- container -->
    <div id="container">
        <!-- LNB -->
        <%@ include file="/WEB-INF/jsp/co/mn/include/left.jsp" %>
        <!-- LNB -->
        
        <div id="contents" class="clearfix">
        
            <!-- location -->
            <%@ include file="/WEB-INF/jsp/co/mn/include/location.jsp" %>
            <!-- location -->
            
            <form id="mainForm" name="mainForm" method="post">
                <input type="hidden" id="currentPageNo" name="currentPageNo" value="${paginationInfo.currentPageNo}" />
                <input type="hidden" id="ltrIdx" name="ltrIdx" value="" />
                <input type="hidden" id="delIdx" name="delIdx"  />
            <div class="searchWrap">
                <p class="pageResult flow">총&nbsp;<span>${paginationInfo.totalRecordCount}</span>건, 현재페이지 ${paginationInfo.currentPageNo}/${paginationInfo.totalPageCount} </p>
                <div class="search reverse">
                        <fieldset>
                            <legend class="invisible">Search</legend>
                            <select>
                                <option value="">제목</option>
                            </select><input type="text" class="formSearch" value="${rqInfo.srchTxt }" id="srchTxt" name="srchTxt" title="검색어" maxlength="10" /><input type="image" class="btnSearch" id="srchButn" name="srchButn" src="/img/mng/btn/btn_search.gif" alt="검색" title="검색" />
                        </fieldset>
                </div>
            </div>
            <table border="1" class="resultTable" summary="뉴스레터 관리 표">
                <colgroup>
                    <col width="5%" />
                    <col width="6%" />
                    <col width="72%" />
                    <col width="17%" />
                </colgroup>
                <thead>
                    <tr>
                        <th><input type="checkbox" id="fCk" name="fCk" value="all" onclick="setAllChk(this, document.mainForm.arrIdx)" /></th>
                        <th>번호</th>
                        <th>제목</th>
                        <th>등록일</th>
                    </tr>
                </thead>
                <tbody>
                <c:choose>
                    <c:when test="${resultList != null && !empty resultList }">
                        <c:forEach var="result" items="${resultList }" varStatus="status">
                    <tr>
                        <td><input type="checkbox" id="arrIdx" name="arrIdx" value="${result.ltrIdx }" /></td>
                        <td>${result.blcNo }</td>
                        <td><a href="#" onclick="moveDtlPage('${result.ltrIdx}');return false;">${result.titl }</a></td>
                        <td>${result.rgstDt}</td>
                    </tr>
                        </c:forEach>
                    </c:when>
                    <c:otherwise>
                    <tr>
                        <td colspan="4">등록된 내용이 없습니다.</td>
                    </tr>
                    </c:otherwise>
                </c:choose>
                </tbody>
            </table>
            </form>
            <div class="btnBoard">
                <span class="flow">
                    <input type="submit" id="delButn" name="delButn" title="삭제" value="삭제" />
                </span>
                <span class="reverse">
                    <input type="submit" id="rgstButn" name="rgstButn" title="등록" value="등록" />
                </span>
            </div>
            <div class="pageNate">
                <able:pagination paginationInfo="${paginationInfo }" type="image" jsFunction="movePage" />
            </div>
        </div>
    </div>
    <!-- /container -->

    <!-- footer -->
    <%@ include file="/WEB-INF/jsp/co/mn/include/bottom.jsp" %>
    <!-- /footer -->
</div>
</body>
</html>